<%@include file="_header.jspf" %>
<%@ page import="com.spartancoder.accommodation.models.AccommodationSession" %>
<%@ page import="com.spartancoder.accommodation.beans.AccommodationSessionBean" %>
<%@ page import="com.spartancoder.accommodation.models.AuthToken" %>
<%@ page import="com.spartancoder.accommodation.models.Options" %>
<%@ page import="com.spartancoder.accommodation.beans.OptionBean" %>
<%
AccommodationSessionBean as = AccommodationSession.fetchLast();
if(as == null) {
    session.setAttribute("flash", "Nu exista nicio sesiune in baza de date");
    response.sendRedirect("list-student.jsp");
} else {
int uId = Integer.parseInt(request.getParameter("id"));
%>

<h2>Listare optiuni <b><%=as.getName()%></b></h2>

<table>
    <thead>
        <tr>
            <th>ID</th>
            <th>Camin</th>
            <th>Camera</th>
            <th>Comentariu</th>
            <th>Optiuni</th>
        </tr>
    </thead>
    <tbody>
        <% for(OptionBean ob : Options.fetchAll(as.getSessionId(), uId)) { %>
        <tr>
            <td><%=ob.getOptionId()%></td>
            <td><%=ob.getPlace().getName()%></td>
            <td><%=ob.getRoom()%></td>
            <td><%=ob.getComment()%></td>
            <td>
                <a href="remove-options.jsp?id=<%=ob.getOptionId()%>&amp;uid=<%=uId%>">
                    sterge
                </a>
            </td>
        </tr>
    <% } %>
    </tbody>
</table>
<% } %>
<%@include file="_footer.jspf" %>